package com.redare.dev.smart.generator.service.service;

import com.redare.dev.smart.generator.sdk.pojo.OnlFormField;
import com.redare.dev.smart.generator.sdk.pojo.form.OnlFormFieldForm;
import com.redare.dev.smart.generator.service.dao.OnlFormFieldDao;
import com.redare.devframework.common.pojo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

;


/**
 * impl
 *
 * @date 2021-08-28 23:03:12
 * Created by yangqiangyu
 */
@Service(value = "com.redare.dev.smart.generator.service.OnlFormFieldService")
public class OnlFormFieldService {

    @Autowired
    OnlFormFieldDao onlFormFieldDao;


    public boolean addOnlFormField(OnlFormFieldForm.Add form) {
        long id = onlFormFieldDao.addOnlFormField(form);
        return id > 0;
    }

    public boolean addOnlFormField(List<OnlFormField> form) {
        return onlFormFieldDao.addOnlFormFieldByBean(form).length>0;
    }

    public boolean editOnlFormField(OnlFormFieldForm.Edit form) {
        return onlFormFieldDao.editOnlFormField(form) > 0;
    }

    public boolean editOnlFormFieldByBean(OnlFormField form) {
        return onlFormFieldDao.editNormalOnlFormFieldByBean(form) > 0;
    }

    public boolean deleteOnlFormField(OnlFormFieldForm.Del form) {
        return onlFormFieldDao.deleteOnlFormField(form) > 0;
    }

    public List<OnlFormField> findOnlFormFieldList(OnlFormFieldForm.Search form) {
        return onlFormFieldDao.findOnlFormFieldPage(form, 1, 20, false, true).getResult();
    }

    public List<OnlFormField> findOnlFormFieldList(OnlFormFieldForm.Search form, int curPage, int pageSize) {
        return onlFormFieldDao.findOnlFormFieldPage(form, curPage, pageSize, false, false).getResult();
    }

    public Page<OnlFormField> findOnlFormFieldPage(OnlFormFieldForm.Search form, int curPage, int pageSize) {
        return onlFormFieldDao.findOnlFormFieldPage(form, curPage, pageSize, true, false);
    }

    public OnlFormField getOnlFormField(OnlFormFieldForm.Get form) {
        return onlFormFieldDao.getOnlFormField(form);

    }


}

